var imgLib = {
  configdefault:{
      url:url,
      url_lib:url+'mod_file_manager/image_manager',
      dir_img:'',
      width: 0,
      height:0,
      method:'imglib',
      action:'',
      callback:'',
      return_tag:''
  },
  config:{},  
  openLib :function (option)
  {
      this.config = $.extend({},this.configdefault,option);
	  
	  this.config.url_lib = this.config.url_lib+'/index/'+this.config.return_tag+'/'+this.config.width+'/'+this.config.height ;
      if(this.config.method=='imgcrop')
	  {
          this.config.url_lib = url+'mod_file_manager/image_manager/cropimage';
      }
	  
      $.colorbox({href:this.config.url_lib,iframe:true, innerWidth:"980px", innerHeight:"600px"});
  },
  
  insert:function(data)
  {
       if(this.config.callback!= '' )
	   {
           this.config.callback(data);
       }
	   else
	   {
           if(this.config.action=='imgcrop')
		   {
                var rt_data = data[0];
                var file = rt_data.lb_dir+'/'+rt_data.lb_name;
                var rt_html = "";
                rt_html += '<input type="hidden" name="'+this.config.return_tag+'" value="images/'+file+'" id="'+this.config.return_tag+'"/>';
                //rt_html += '<a href="'+url+'mod_file_manager/image_manager/cropimage/'+this.config.return_tag+'/'+this.config.width+'/'+this.config.height+'" class="cboxElement" title="Image Crop"><img src="'+urlsite+'uploads/images/'+file+'" width="100px"/></a>';
                rt_html += '<a href="javascript:imgLib.openLib({dir_img:\'images/'+file+'\',width:\''+this.config.width+'\',height:\''+this.config.height+'\',method:\'imgcrop\',return_tag:\''+this.config.return_tag+'\',action:\'imgcrop\'});"> <img src="'+urlsite+'uploads/images/'+file+'" width="100px"/></a>';
                $("."+this.config.return_tag).html(rt_html);
                $(".cboxElement").colorbox({width:"985px", height:"600px",iframe:true});
           }
		   else if(this.config.action=='editor')
		   {
               
           }
       }
  },
  crop:function(data)
  {
    if(this.config.callback!= '' ){
        this.config.callback(data);
    }else{
        if(this.config.action=='imgcrop'){
            var rt_html = "";
            rt_html += '<input type="hidden" name="'+this.config.return_tag+'" value="temp/'+data.file_name+'" id="'+this.config.return_tag+'"/>';
            rt_html += '<a onclick="imgLib.openLib({dir_img:\'temp/'+data.file_name+'\',width:\''+this.config.width+'\',height:\''+this.config.height+'\',method:\'imgcrop\',return_tag:\''+this.config.return_tag+'\',action:\'imgcrop\'});" href="javascript:void(0);"> <img src="'+urlsite+'uploads/temp/'+data.file_name+'" width="100px"/></a>';
            $("."+this.config.return_tag).html(rt_html);
            $(".cboxElement").colorbox({width:"950", height:"650",iframe:true});
        }
    }
  }
};